package edu.washington.cs.workflow.recommender;

import java.util.List;

import edu.washington.cs.workflow.analysis.AnalysisBuilder.CG;
import edu.washington.cs.workflow.analysis.AnalysisBuilder.UIFramework;
import edu.washington.cs.workflow.matching.ExecutionTraceMatcher;
import edu.washington.cs.workflow.matching.ExecutionTraceMatcherFactory;
import edu.washington.cs.workflow.matching.TestGanttProject;
import edu.washington.cs.workflow.matching.TestMatchingFreemind;
import edu.washington.cs.workflow.util.Log;
import edu.washington.cs.workflow.util.Utils;

import junit.framework.TestCase;

public class TestReplacementActionRecommender extends TestCase {

	public void testCrossword() {
		String oldTrace = "./tests/demo-traces/crossword-new-puzzle-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/crossword_all_actions_new_version.txt"};
		
        String[] pkgs = new String[]{"crosswordsage"};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.jar";
		String oldMain = "Lcrosswordsage/MainScreen";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.5.jar";
		String newMain = "Lcrosswordsage/MainScreen";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("New Crossword,") != -1);
	}
	
	public void testCrossword_new() {
		String oldTrace = "./tests/demo-traces/crossword-new-puzzle-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/crossword_all_actions_new_version.txt"};
		
        String[] pkgs = new String[]{"crosswordsage"};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.jar";
		String oldMain = "Lcrosswordsage/MainScreen";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.5.jar";
		String newMain = "Lcrosswordsage/MainScreen";
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testCrossword_static() {
		String oldTrace = "./tests/demo-traces/crossword-new-puzzle-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/crossword_all_actions_new_version.txt"};
		
        String[] pkgs = new String[]{"crosswordsage"};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.jar";
		String oldMain = "Lcrosswordsage/MainScreen";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.5.jar";
		String newMain = "Lcrosswordsage/MainScreen";
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testCrossword_breath() {
		String oldTrace = "./tests/demo-traces/crossword-new-puzzle-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/crossword_breath_first_new_version.txt"};
		
        String[] pkgs = new String[]{"crosswordsage"};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.jar";
		String oldMain = "Lcrosswordsage/MainScreen";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\crossword-0.3.5.jar";
		String newMain = "Lcrosswordsage/MainScreen";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("New Crossword,") != -1);
	}
	
	public void testCrossword_stat() {
		String oldTrace = "./tests/demo-traces/crossword-new-puzzle-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/crossword_all_actions_new_version.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("New Crossword,") != -1);
	}
	
	public void testJEdit() {
		String oldTrace = "./tests/demo-traces/jedit-prev-next-buffer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jedit_prev_next_buffer_new_version.txt"};
		
		String[] pkgs = new String[]{"org.gjt.sp."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.5.jar";
		String oldMain = "Lorg/gjt/sp/jedit/jEdit";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.6.jar";
		String newMain = "Lorg/gjt/sp/jedit/jEdit";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Go to Previous Buffer") != -1);
		assertTrue(actions.get(1).indexOf("Go to Next Buffer") != -1);
	}
	
	public void testJEdit_new() {
		String oldTrace = "./tests/demo-traces/jedit-prev-next-buffer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jedit_prev_next_buffer_new_version.txt"};
		
		String[] pkgs = new String[]{"org.gjt.sp."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.5.jar";
		String oldMain = "Lorg/gjt/sp/jedit/jEdit";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.6.jar";
		String newMain = "Lorg/gjt/sp/jedit/jEdit";
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJEdit_static() {
		String oldTrace = "./tests/demo-traces/jedit-prev-next-buffer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jedit_prev_next_buffer_new_version.txt"};
		
		String[] pkgs = new String[]{"org.gjt.sp."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.5.jar";
		String oldMain = "Lorg/gjt/sp/jedit/jEdit";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.6.jar";
		String newMain = "Lorg/gjt/sp/jedit/jEdit";
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
		System.out.println("Results: " + actions);
		
	}
	
	public void testJEdit_breath() {
		String oldTrace = "./tests/demo-traces/jedit-prev-next-buffer-old-version.txt";
		String[] newTraces = new String[]{"./trace_file.txt"};
		
		String[] pkgs = new String[]{"org.gjt.sp."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.5.jar";
		String oldMain = "Lorg/gjt/sp/jedit/jEdit";
		
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jedit-2.6.jar";
		String newMain = "Lorg/gjt/sp/jedit/jEdit";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Go to Previous Buffer") != -1);
		assertTrue(actions.get(1).indexOf("Go to Next Buffer") != -1);
	}
	
	public void testJEdit_stat() {
		String oldTrace = "./tests/demo-traces/jedit-prev-next-buffer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jedit_prev_next_buffer_new_version.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Go to Next Buffer") != -1);
		assertTrue(actions.get(1).indexOf("Go to Previous Buffer") != -1);
	}
	
	public void testJabRef_search() {
		String oldTrace = "./tests/demo-traces/jabref-search-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println("size: " + actions.size());
		assertTrue(actions.get(0).indexOf(", Search,") != -1);
	}
	
	public void testJabRef_search_new() {
		String oldTrace = "./tests/demo-traces/jabref-search-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_search_static() {
		String oldTrace = "./tests/demo-traces/jabref-search-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_search_stat() {
		String oldTrace = "./tests/demo-traces/jabref-search-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(1).indexOf(", Search,") != -1);
	}
	
	public void testJabRef_import() {
		String oldTrace = "./tests/demo-traces/jabref-import-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
//		assertTrue(actions.isEmpty());
		assertTrue(actions.get(0).indexOf("Import into new database") != -1);
	}
	
	public void testJabRef_import_new() {
		String oldTrace = "./tests/demo-traces/jabref-import-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_import_static() {
		String oldTrace = "./tests/demo-traces/jabref-import-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_import_stat() {
		String oldTrace = "./tests/demo-traces/jabref-import-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		fail();
//		assertTrue(actions.get(1).indexOf(", Search,") != -1);
	}
	
	public void testJabRef_import_and_append() {
		Log.logConfig("./log.txt");
		Utils.debuglog = true;
		String oldTrace = "./tests/demo-traces/jabref-import-and-append-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		Log.removeLogging();
		assertTrue(actions.get(0).indexOf("Import into new database") != -1);
	}
	
	public void testJabRef_import_and_append_stat() {
		String oldTrace = "./tests/demo-traces/jabref-import-and-append-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
	}
	
	//Hardcode the results
	//FIXME
	public void testJabRef_export() {
		String oldTrace = "./tests/demo-traces/jabref-export-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
		System.out.println(actions);
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
//		fail();
		assertTrue(actions.get(0).indexOf("File, Export, ") != -1);
	}
	
	public void testJabRef_export_new() {
		String oldTrace = "./tests/demo-traces/jabref-export-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_export_static() {
		String oldTrace = "./tests/demo-traces/jabref-export-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		
		String[] pkgs = new String[]{"net.sf.jabref."};
		String oldClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.0\\JabRef-2.0-binary.jar";
		String newClassPath = "D:\\research\\configurations\\workspace\\workflow-error-repair\\experiments\\jabref2.8\\JabRef-2.8.1.jar";
		String oldMain = "Lnet/sf/jabref/JabRef";
		String newMain = "Lnet/sf/jabref/JabRef";
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testJabRef_export_stat() {
		String oldTrace = "./tests/demo-traces/jabref-export-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/jabref_all_actions_new_version_24m.txt"};
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		fail();
	}
	
	public void testEditPreference_foldAll() {
		//this function is removed in the new version
		//optionHTMLExportFoldingAction = new OptionHTMLExportFoldingAction(this);
		fail();
	}
	
	public void testFreemind_export() {
		Log.logConfig("./log.txt");
		Utils.debuglog = true;
		String oldTrace = "./tests/demo-traces/freemind-export-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_file_export_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		Log.removeLogging();
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("File, Export, As HTML") != -1); //WHY NOT the first rank?
	}
	
	public void testFreemind_export_new() {
		String oldTrace = "./tests/demo-traces/freemind-export-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_file_export_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_export_static() {
//		Log.logConfig("./log.txt");
//		Utils.debuglog = true;
		String oldTrace = "./tests/demo-traces/freemind-export-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_file_export_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_export_stat() {
		String oldTrace = "./tests/demo-traces/freemind-export-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_file_export_html_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("File, Export, As HTML") != -1); //WHY NOT the first rank?
	}
	
	public void testFreemind_nextfile() {
		String oldTrace = "./tests/demo-traces/freemind-prev-next-map-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_next_file_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Maps, Next Map") != -1);
//		fail();
	}
	
	public void testFreemind_nextfile_new() {
		String oldTrace = "./tests/demo-traces/freemind-prev-next-map-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_next_file_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_nextfile_static() {
		String oldTrace = "./tests/demo-traces/freemind-prev-next-map-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_next_file_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_nextfile_stat() {
		String oldTrace = "./tests/demo-traces/freemind-prev-next-map-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_next_file_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Maps, Next Map") != -1);
	}
	
	public void testFreemind_toggled() {
		String oldTrace = "./tests/demo-traces/freemind-toggled-folded-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_toggle_folded_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Toggle Folded") != -1);
//		assertTrue(actions.isEmpty());
	}
	
	public void testFreemind_toggled_new() {
		String oldTrace = "./tests/demo-traces/freemind-toggled-folded-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_toggle_folded_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_toggled_static() {
		String oldTrace = "./tests/demo-traces/freemind-toggled-folded-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_toggle_folded_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_toggled_stat() {
		String oldTrace = "./tests/demo-traces/freemind-toggled-folded-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_toggle_folded_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(1).indexOf("Toggle Folded") != -1);
	}
	
	public void testFreemind_export_branch_as_html() {
		String oldTrace = "./tests/demo-traces/freemind-export-branch-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_branch_as_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Branch as HTML") != -1);
	}
	
	public void testFreemind_export_branch_as_html_new() {
		String oldTrace = "./tests/demo-traces/freemind-export-branch-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_branch_as_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_export_branch_as_html_static() {
		String oldTrace = "./tests/demo-traces/freemind-export-branch-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_branch_as_html_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_export_branch_as_html_stat() {
		String oldTrace = "./tests/demo-traces/freemind-export-branch-as-html-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_branch_as_html_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Branch as HTML") != -1);
	}
	
	public void testFreemind_edge_style() {
		String oldTrace = "./tests/demo-traces/freemind-edit-style-beizer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_edge_bezier_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Format, Edge Styles, Bezier,") != -1);
	}
	
	public void testFreemind_edge_style_new() {
		String oldTrace = "./tests/demo-traces/freemind-edit-style-beizer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_edge_bezier_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_edge_style_static() {
		String oldTrace = "./tests/demo-traces/freemind-edit-style-beizer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_edge_bezier_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemind_edge_style_stat() {
		String oldTrace = "./tests/demo-traces/freemind-edit-style-beizer-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_edge_bezier_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(1).indexOf("Format, Edge Styles, Bezier") != -1);
	}
	
	public void testFreemindZoomIn() {
		String oldTrace = "./tests/demo-traces/freemind-zoom-in-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_zoom_in_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("View, Zoom In, ") != -1);
	}
	
	public void testFreemindZoomIn_new() {
		String oldTrace = "./tests/demo-traces/freemind-zoom-in-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_zoom_in_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testFreemindZoomIn_static() {
		String oldTrace = "./tests/demo-traces/freemind-zoom-in-old-version.txt";
		String[] newTraces = new String[]{"./tests/files/freemind_zoom_in_new_version.txt"};
		
		String[] pkgs = TestMatchingFreemind.pkgs;
		String oldClassPath = TestMatchingFreemind.oldDir;
		String newClassPath = TestMatchingFreemind.newDir;
		String oldMain = TestMatchingFreemind.main;
		String newMain = TestMatchingFreemind.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_zoom_in_out() {
		String oldTrace = "./tests/demo-traces/gantt_project_zoom_in_out_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_zoom_in_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
//		assertTrue(actions.isEmpty());
		assertTrue(actions.get(0).indexOf("Zoom In,") != -1);
	}
	
	public void testGantt_zoom_in_out_new() {
		String oldTrace = "./tests/demo-traces/gantt_project_zoom_in_out_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_zoom_in_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
	}
	
	public void testGantt_zoom_in_out_static() {
		String oldTrace = "./tests/demo-traces/gantt_project_zoom_in_out_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_zoom_in_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_zoom_in_out_stat() {
		String oldTrace = "./tests/demo-traces/gantt_project_zoom_in_out_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_zoom_in_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Zoom In") != -1);
	}
	
	public void testGantt_critical() {
		String oldTrace = "./tests/demo-traces/gantt_project_critical_path_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_critical_path_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(0).indexOf("Show critical path,") != -1);
	}
	
	public void testGantt_critical_new() {
		String oldTrace = "./tests/demo-traces/gantt_project_critical_path_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_critical_path_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_critical_static() {
		String oldTrace = "./tests/demo-traces/gantt_project_critical_path_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_critical_path_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_critical_stat() {
		String oldTrace = "./tests/demo-traces/gantt_project_critical_path_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_critical_path_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Show critical path,") != -1);
	}
	
	public void testGantt_next() {
		String oldTrace = "./tests/demo-traces/gantt_project_next_prev_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_next_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
//		assertTrue(actions.isEmpty());
		assertTrue(actions.get(0).indexOf("Next, ") != -1);
	}
	
	public void testGantt_next_static() {
		String oldTrace = "./tests/demo-traces/gantt_project_next_prev_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_next_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_next_new() {
		String oldTrace = "./tests/demo-traces/gantt_project_next_prev_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_next_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		Log.removeLogging();
	}
	
	public void testGantt_next_stat() {
		String oldTrace = "./tests/demo-traces/gantt_project_next_prev_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_next_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Next,") != -1);
	}
	
	//chart option, can not precisely locate the location
	public void testGantt_setting() {
		String oldTrace = "./tests/demo-traces/gantt_project_gantt_chart_option_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_settings_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
//		assertTrue(actions.isEmpty());
		assertTrue(actions.get(0).indexOf("Edit, Settings") != -1);
	}
	
	public void testGantt_setting_new() {
		String oldTrace = "./tests/demo-traces/gantt_project_gantt_chart_option_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_settings_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
	}
	
	public void testGantt_setting_static() {
		String oldTrace = "./tests/demo-traces/gantt_project_gantt_chart_option_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_settings_new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_setting_stat() {
		String oldTrace = "./tests/demo-traces/gantt_project_gantt_chart_option_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_settings_new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(0).indexOf("Edit, Settings") != -1);
	}
	
	public void testGantt_save() {
		Log.logConfig("./log.txt");
		Utils.debuglog = true;
		
		String oldTrace = "./tests/demo-traces/gantt_project_save_previous_state_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_save_previous_state-hack-error-in-save-new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
		
//		List<String> actions = this.recommendActions(oldTrace, newTraces);
		System.out.println(actions);
		assertTrue(actions.get(1).indexOf("Edit table input name") != -1);
		
	}
	
	public void testGantt_save_new() {
		String oldTrace = "./tests/demo-traces/gantt_project_save_previous_state_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_save_previous_state-hack-error-in-save-new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendNewActions(oldTrace, newTraces,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
	}
	
	public void testGantt_save_static() {
//		Utils.debuglog = true;
//		Log.logConfig("gantt_save_new.txt");
		String oldTrace = "./tests/demo-traces/gantt_project_save_previous_state_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_save_previous_state-hack-error-in-save-new_version.txt"};
		
		String[] pkgs = TestGanttProject.pkgs;
		String oldClassPath = TestGanttProject.oldDir;
		String newClassPath = TestGanttProject.newDir;
		String oldMain = TestGanttProject.main;
		String newMain = TestGanttProject.main;
		
		List<String> actions = recommendActionsStatically(oldTrace,
				oldClassPath, oldMain, pkgs, newClassPath, newMain, pkgs,
				UIFramework.SWING, CG.RTA);
//		Log.removeLogging();
	}
	
	public void testGantt_save_stat() {
		String oldTrace = "./tests/demo-traces/gantt_project_save_previous_state_old_version.txt";
		String[] newTraces = new String[]{"./tests/files/gantt_project_save_previous_state-hack-error-in-save-new_version.txt"};
		
		List<String> actions = this.recommendActionsByUniqueness(oldTrace, newTraces);
		System.out.println("\n");
		for(String a : actions) {
			System.out.println(a);
		}
		assertTrue(actions.get(1).indexOf("Edit table input name") != -1);
	}
	
	/**
	 * Below are all helper methods
	 * */
	private List<String> recommendActions(String oldTrace, String[] newTraces) {
		ReplacementActionRecommender recommender = new ReplacementActionRecommender(oldTrace, newTraces);
		return recommender.recommendActions();
	}
	
	private List<String> recommendActions(String oldTrace, String[] newTraces,
			String oldClassPath, String oldMain, String[] oldPackages,
			String newClassPath, String newMain, String[] newPackages,
			UIFramework framework, CG type) {
		ReplacementActionRecommender recommender = new ReplacementActionRecommender(oldTrace, newTraces);
		ExecutionTraceMatcher matcher = ExecutionTraceMatcherFactory.
		        createExecutionTraceMatcher(
				oldClassPath, oldMain, oldPackages,
				newClassPath, newMain, newPackages,
				framework, type);
		recommender.setTraceMatcher(matcher);
		
		List<String> actions = recommender.recommendActions(true); //exactly matched
		
		if(actions.isEmpty()) {
			Utils.debugPrintln("Looking for similar methods ");
			actions = recommender.recommendActions(false); //similar methods
		}
		
		return actions;
	}
	
	private List<String> recommendNewActions(String oldTrace, String[] newTraces,
			String oldClassPath, String oldMain, String[] oldPackages,
			String newClassPath, String newMain, String[] newPackages,
			UIFramework framework, CG type) {
		ReplacementActionRecommender recommender = new ReplacementActionRecommender(oldTrace, newTraces);
		ExecutionTraceMatcher matcher = ExecutionTraceMatcherFactory.
		        createExecutionTraceMatcher(
				oldClassPath, oldMain, oldPackages,
				newClassPath, newMain, newPackages,
				framework, type);
		recommender.setTraceMatcher(matcher);
		
		List<String> actions = recommender.recommendNewActions();
		
		return actions;
	}
	
	private List<String> recommendActionsStatically(String oldTrace,
			String oldClassPath, String oldMain, String[] oldPackages,
			String newClassPath, String newMain, String[] newPackages,
			UIFramework framework, CG type) {
		
		ExecutionTraceMatcher matcher = ExecutionTraceMatcherFactory.
            createExecutionTraceMatcher(
		    oldClassPath, oldMain, oldPackages,
		    newClassPath, newMain, newPackages,
		    framework, type);
		
		ReplacementActionRecommender_Static recommender = new ReplacementActionRecommender_Static(oldTrace, new String[]{}, matcher.newBuilder);
		
		recommender.setTraceMatcher(matcher);
		
		List<String> actions = recommender.recommendNewActions();
		
		return actions;
	}
	
	/**
	 * Recommend actions by uniqueness
	 * */
	private List<String> recommendActionsByUniqueness(String oldTrace, String[] newTraces) {
		ReplacementActionRecommender recommender = new ReplacementActionRecommender(oldTrace, newTraces);
		List<String> actions = recommender.recommendActionsByUniqueness();
		return actions;
	}
}